from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import reverse
from jinja2 import Environment


def create_environment(**option):
    """
    创建 jinja2 的环境对象
    :param option:
    :return:
    """
    environment = Environment(**option)
    environment.globals.update({
        'static': staticfiles_storage.url,
        'url': reverse,
    })
    return environment
